//Collection

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

public class TestDemo {
    public static void main(String[] args) {
        Collection<String> collection = new ArrayList<String>();
        collection.add("hello");
        //collection.add(1); 被泛型修饰有限制

        Collection<Integer> collection1 = new ArrayList<>();
        collection1.add(1);
        System.out.println(collection1);

        //clear方法
        collection1.clear();
        System.out.println(collection1);

        //将集合转化为数组
        Object[] objects = collection1.toArray();

        //这样会报错,java数组尽量不用强制类型转换
        //String[] a = (String[])collection.toArray();
        System.out.println(Arrays.toString(objects));
    }
}
